{% extends 'index.html' %}
{% load static %}
{% load thumbnail %}

{% block title %}Заметки пользователя {{ owner }} {% endblock %}

{% block posts %}

{% for log in page_obj %}

<article class="post">
	<header>
		<div class="title">
			<h2><a href="{% url 'logs:log' log.id %}">{{ log.description }}</a></h2>
			{% comment %} <p>{% url 'logs:log' log.id %}</p> {% endcomment %}
		</div>
		<div class="meta">
			<time class="published" datetime="#">{{ log.date_added|date:"d E Y" }}</time>
			{% thumbnail log.owner.avatar "100x100" crop="center" upscale=True as im %}
				<a href="{% url 'logs:user_logs' log.owner.get_username %}" class="author"><span class="name">{{ log.owner.get_username }}</span><img src="{{ im.url }}" alt="" /></a>
			{% endthumbnail %}
		</div>
	</header>
	<p>{{ log.text|safe|truncatechars_html:100 }}</p>
	<footer>
		<ul class="actions">
			<li><a href="{% url 'logs:log' log.id %}" class="button large">Читать</a></li>
		</ul>
		<ul class="stats">
			{% if log.owner == request.user  %}
			<li><a href="{% url 'logs:edit_log' log.id %}">Редактировать запись</a></li>
			{% endif %} 
			<li><a href="#" onclick="return false;" class="icon solid fa-heart">{{ log.likes.count }}</a></li>
			<li><a href="#" onclick="return false;" class="icon solid fa-comment">{{ log.comments.count }}</a></li>
		</ul>
	</footer>
</article>

{% empty %}
<article class="post">
	<p><h4>У вас пока нет записей..</h4></p>
</article>
	{% endfor %}

{% endblock %}